// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import axios from 'axios'
import router from './router'
import store from './store'
import * as filters from './filters'

// import VueResource from 'vue-resource'
// Vue.use(VueResource)
Vue.prototype.$ajax = axios;

import Promise from 'es6-promise'
Promise.polyfill()

import jquery from './assets/js/jquery.js'
import jqueryUiJs from './assets/js/jquery-ui.js'
// import bootstrapJs from './assets/js/bootstrap.js'
import layerJs from './assets/layer/layer.js'
import commonJs from './assets/js/common.js'
// import popoverJs from './assets/js/popover.js'
import printareaJs from './assets/js/jquery.printarea.js'

// import bootstrapCss from './assets/css/bootstrap.css'
import layerCss from './assets/layer/theme/default/layer.css'
import jqueryUiCss from './assets/css/jquery-ui.css'
// import popoverCss from './assets/css/popover.css'
import mixinCss from './assets/css/mixin.scss'

import baseCss from './assets/css/base.scss'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})

// 判断登录状态与版本状态
Vue.prototype.codes= function(mag){
  if(mag == '10001'){
    this.$router.push({path:'/'})
  }else if(mag == '10002'){
    this.$layer.msg('版本警告');
  }else if(mag == '10003'){
    this.$layer.msg('版本已停用');
  }
};

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// 数据加载时的状态
Vue.prototype.loading= function(){
  $('body').append('<div class="loading"></div>');
}
// 数据加载完去掉加载状态
Vue.prototype.removeLoading= function(){
  $('.loading').remove();
}
// 页码
Vue.prototype.pagination= function(url,page){
  var Pagination={'url':url,'page':page}
  sessionStorage.setItem("Pagination",JSON.stringify(Pagination));
}
Vue.prototype.paginations= function(pages){
  var Pagination=JSON.parse(sessionStorage.getItem('Pagination'));
  if(Pagination==null){
    Pagination={'url':window.location.href,'page':1}
    pages=Pagination.page=1;
    return pages;
  }else if(Pagination.url==window.location.href){
    pages=Pagination.page;
    return pages;
  }else{
    pages=Pagination.page=1;
    return pages;
  }
}
